'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DECIMAL, TINYINT } = Sequelize;
    
    // 添加客户价值相关字段
    await queryInterface.addColumn('customers', 'customer_type', {
      type: STRING(50),
      comment: '客户类型'
    });
    
    await queryInterface.addColumn('customers', 'customer_level', {
      type: STRING(50),
      comment: '客户等级'
    });
    
    await queryInterface.addColumn('customers', 'customer_source', {
      type: STRING(100),
      comment: '客户来源'
    });
    
    await queryInterface.addColumn('customers', 'credit_rating', {
      type: STRING(10),
      comment: '信用评级'
    });
    
    await queryInterface.addColumn('customers', 'credit_score', {
      type: INTEGER,
      comment: '信用分数'
    });
    
    await queryInterface.addColumn('customers', 'responsible_salesman', {
      type: STRING(100),
      comment: '负责销售'
    });
    
    await queryInterface.addColumn('customers', 'last_order_date', {
      type: Sequelize.DATE,
      comment: '最后下单时间'
    });
  },

  down: async (queryInterface, Sequelize) => {
    // 删除添加的字段
    await queryInterface.removeColumn('customers', 'customer_type');
    await queryInterface.removeColumn('customers', 'customer_level');
    await queryInterface.removeColumn('customers', 'customer_source');
    await queryInterface.removeColumn('customers', 'credit_rating');
    await queryInterface.removeColumn('customers', 'credit_score');
    await queryInterface.removeColumn('customers', 'responsible_salesman');
    await queryInterface.removeColumn('customers', 'last_order_date');
  }
};